﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF_LoginUI
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window,INotifyPropertyChanged
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = this;
            userName = "请输入用户名";
            password = "请输入密码";
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private string _userName;

        public string userName
        {
            get { return _userName; }
            set { 
                _userName = value;
                RaisePropertyChanged("userName");
            }
        }
        private string _password;

        public string password
        {
            get { return _password; }
            set
            {
                _password = value;
                RaisePropertyChanged("password");
            }
        }
        
        //public string userName { get; set; } = "请输入用户名";
        //public string password { get; set; } = "请输入密码";
        private void signUp_Click(object sender, RoutedEventArgs e)
        {

            //string userNameT = userName.Text;
            //string passwordT = password.Text;
            if (userName == "123123" && password == "456456")
            {
                //弹出新的界面
                Index index = new Index();
                index.Show();
                this.Hide();
            }
            else
            {
                //弹出警告框
                MessageBox.Show("输入的用户名或密码不正确");
            }
        }

        private void TextBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if(userName == "请输入用户名")
            {
                userName = "";
            }
        }

        private void TextBox_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            if (password == "请输入密码")
            {
                password = "";
            }
        }
    }
}
